package util;


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
/**
 * A set of String which is loaded from a file
 */
public class StringSet {
    private Set<String> stringSet;
    public StringSet(String path) throws IOException {
        this(path, "UTF-8");
    }
    public StringSet(String path, String encoding) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(path), encoding));
        stringSet = new HashSet<String>();
        while(true) {
            String line = in.readLine();
            if(line == null) {
                break;
            }
            stringSet.add(line);
        }
        in.close();
    }
    public boolean contains(String s){
        return stringSet.contains(s);
    }
}
